package com.mq.controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author LeeXyan
 * @Date 2017/8/3 0003
 * @time 17:11
 *
 * 接着就可以发送消息啦!在SpringBoot中,我们使用AmqpTemplate去发送消息
 */
@Component
public class Sender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send() {
        System.out.println("sssssssssss");
        String context = "hello " + new Date();
        System.out.println("Sender : " + context);
        this.amqpTemplate.convertAndSend("hello", context);
        /*amqpTemplate.convertAndSend("queue","hello,rabbit~");*/
    }
}
